<template>
  <div>
    <el-select v-if="showTemplate" v-model="templateId" >
      <el-option
        v-for="item in templateList"
        :key="item.templateId"
        :label="item.name"
        :value="item.templateId"
      />
    </el-select>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="returnId">确 定</el-button>
    </span>
  </div>
</template>

<script>
import request from '@/utils/request'

export default {
  name: 'JCustomer',
  props: {
    groupId: [String, Number]
  },
  data() {
    return {
      templateId: null,
      templateList: [],
      showTemplate:true
    }
  },
  created() {
    this.query()
    this.templateId = localStorage.getItem('getPrintId'+this.groupId) || ''
  },

  methods: {
    query() {
      request({
        url: '/api/dropDown/printConfigList',
        method: 'get',
        params: {
          code: this.groupId
        }
      }).then(res => { 
        this.templateList = res.content 
        this.showTemplate = false
        this.$nextTick(()=>{
          this.showTemplate = true
        })
      })
    },
    returnId() {
      this.$emit('getPrintId', this.templateId)
      localStorage.setItem('getPrintId'+this.groupId,this.templateId)
    }
  }
}
</script>

<style scoped>

</style>
